Conversation
|
@fengmk2, thanks for your PR! By analyzing the history of the files in this pull request, we identified @gxcsoccer, @dead-horse and @pmq20 to be potential reviewers. |
| // 0x800: 2048 | ||
| this._bytes[index++] = (0xc0 + ((ch >> 6) & 0x1f)) >>> 32; | ||
| this._bytes[index++] = (0x80 + (ch & 0x3f)) >>> 32; | ||
| // this._bytes[index++] = (0xc0 + ((ch >> 6) & 0x1f)) >>> 32; |
There was a problem hiding this comment.
看上去 (0xc0 + ((ch >> 6) & 0x1f)) 和 (0x80 + (ch & 0x3f)) 的运算符都是正数,所以不会加出负数,因此去掉 >>> 32 是逻辑一致的。
pmq20
left a comment
There was a problem hiding this comment.
看上去 (0xc0 + ((ch >> 6) & 0x1f)) 和 (0x80 + (ch & 0x3f)) 的运算符都是正数,所以不会加出负数,因此去掉 >>> 32 是逻辑一致的。
| // 0x800: 2048 | ||
| this._bytes[index++] = (0xc0 + ((ch >> 6) & 0x1f)) >>> 32; | ||
| this._bytes[index++] = (0x80 + (ch & 0x3f)) >>> 32; | ||
| // this._bytes[index++] = (0xc0 + ((ch >> 6) & 0x1f)) >>> 32; |
There was a problem hiding this comment.
看上去 (0xc0 + ((ch >> 6) & 0x1f)) 和 (0x80 + (ch & 0x3f)) 的运算符都是正数,所以不会加出负数,因此去掉 >>> 32 是逻辑一致的。
|
然而还要看是否有溢出的情况,我看看 |
|
ch 的最大值是 65536,因此(0xc0 + ((ch >> 6) & 0x1f)) 和 (0x80 + (ch & 0x3f)) 的最大值分别是 192 和 128,不会超出 4294967296 因此不需要 |
BTW: js CESU-8 encoding is faster then Buffer UTF-8 encoding ``` putRawStringSmallLessThan0x80*10000: 672.642ms putRawStringSmallLessThan0x800*10000: 592.960ms putRawStringSmallBiggerThan0x800*10000: 861.010ms putUTF8RawStringSmallLessThan0x80*10000: 841.638ms putUTF8RawStringSmallLessThan0x800*10000: 958.383ms putUTF8RawStringSmallBiggerThan0x800*10000: 1793.470ms ```
0911c1b to
7fa2f4c
Compare
BTW: js CESU-8 encoding is faster then Buffer UTF-8 encoding